/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-19 09:30:13
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-19 14:49:25
 */
import 'package:flutter_data_center/model/common/menu_model.dart';
import 'package:flutter_data_center/model/warning/warning_model.dart';
import 'package:flutter_data_center/net/dio_utils.dart';
import 'package:get/get.dart';

class WarningController extends GetxController {
  // 隐患列表
  List<WarningModel> _warnings = [];
  List get warnings => _warnings;
  void getWarnings() async {
    _warnings = [];
    ResponseInfo responseInfo = await DioUtils.instance.getRequest(
      url: HttpHelper.warningList,
    );
    if (responseInfo.success) {
      var data = responseInfo.data;
      for (var item in data) {
        _warnings.add(WarningModel.fromJson((item)));
      }
      update();
    }
  }

  // 菜单
  List<MenuModel> _menus = [
    MenuModel("未处理", "untreated"),
    MenuModel("已处理", "processed"),
  ];
  List<MenuModel> get menus => _menus;

  // 预警类型
  List<MenuModel> _warningsType = [
    MenuModel("建筑", "building"),
    MenuModel("设备", "equipment"),
    MenuModel("人员", "staff"),
    MenuModel("其他", "other"),
  ];

  List<MenuModel> get warningsType => _warningsType;

  // 预警级别
  List<MenuModel> _warningLevel = [
    MenuModel("一级", "a"),
    MenuModel("二级", "b"),
    MenuModel("三级", "c"),
    MenuModel("四级", "d"),
  ];

  List<MenuModel> get warningLevel => _warningLevel;
}
